<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>
<style>
    table tbody {
        display: block;
        height: 195px;
        overflow-y: scroll;
    }

    table thead,
    tbody tr {
        display: table;
        width: 100%;
        table-layout: fixed;
    }

    /*table thead {
    width: calc( 100% - 1em )
}*/
</style>

<body>
    <header class="aui-bar aui-bar-nav main-header">
        <a class="aui-pull-left aui-btn" tapmode onclick="closeWin();">
            <span class="aui-iconfont aui-icon-left"></span>
        </a>
        <div class="aui-title" id="title">
            采购退货
        </div>
    </header>
    <div class="aui-bar aui-bar-nav sub-header"></div>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <div class="white_background">
            <ul class="aui-list aui-form-list">

                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">仓库</div>
                        <div class="aui-list-item-input">
                            <input type="text" placeholder="选择/扫描 仓库" id="workCenterCode" value=""
                                onclick="getIdSelector();" />
                        </div>
                        <i class="aui-input-addon aui-iconfont aui-icon-right" onclick="goSelectWorkCenter()"></i>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">库位</div>
                        <div class="aui-list-item-input">
                            <input type="text" placeholder="选择/扫描 库位" id="workCellCode" value=""
                                onclick="getIdSelector();" />
                        </div>
                        <i class="aui-input-addon aui-iconfont aui-icon-right" onclick="goSelectWorkCell()"></i>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">箱号</div>
                        <div class="aui-list-item-input">
                            <input type="text" placeholder="请扫描箱号" id="boxnum" value="" onclick="getIdSelector();">
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">供应商</div>
                        <div class="aui-list-item-input">
                            <input type="text" id="supplier" readonly>
                        </div>
                    </div>
                </li>
                <li class="aui-list-item" style="display:none">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">条码</div>
                        <div class="aui-list-item-input">
                            <input type="text" id="tm">
                        </div>
                    </div>
                </li>
                <li class="aui-list-item" style="display:none">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">条码ID</div>
                        <div class="aui-list-item-input">
                            <input type="text" id="tmID">
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">备注</div>
                        <div class="aui-list-item-input">
                            <input type="text" id="remark">
                        </div>
                    </div>
                </li>
            </ul>
        </div>
        <div class="aui-btn aui-btn-info aui-btn-block" onclick="save()" id="submitButton">保存</div>
        <div class="white_background">
            <div class="table-responsive" id="appStorage" style="overflow-y:auto;height: 13rem;">
                <table id="tableS" class="table table-bordered " style="table-layout: fixed;">
                    <thead>
                        <tr id="tr1"
                            style="text-align: center;background-color: #DCE9F2;color: #467aa7;font-family: 微软雅黑;font-size: 13px;font-weight: bold;">
                            <td style="width:120px;">箱号</td>
                            <td style="width:120px;;">物料号</td>
                            <td style="width:120px;">批次号</td>
                            <td style="width:120px;">数量</td>
                            <td style="width:120px;">仓库</td>
                            <td style="width:120px;">库位</td>
                            <td style="width:120px;">供应商编码</td>
                        </tr>
                    </thead>
                    <tbody id="tbodyHtml"
                        style='text-align: center;color: black;font-size: 12px;background-color: #F5F5F5;'>


                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <footer class="aui-bar aui-bar-tab" id="footer">
        <div class="aui-bar-tab-item" tapmode id="scan" onclick="doScan()">
            <i class="aui-iconfont aui-icon-scan aui-text-epblue" style="font-size: 1.8rem"></i>
        </div>
    </footer>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript" src="../script/clickThrottle.js"></script>
<script type="text/javascript">
    //光标所在id
    var idSelector = "";
    var workCenterGid = ""; //仓库GID
    var workCenterCode = ""; //仓库编码
    var workCenterName = ""; //仓库名称
    var workCellGid = ""; //库位GID
    var workCellCode = ""; //库位编码
    var workCellName = ""; //库位名称
    var remark = ""; //备注

    var scanRule = ""; //条码解析规则

    var arrSave = [];//需要提交的箱信息
    var html = "";

    var supplier = "" //供应商
    //初始化查询仓库下拉框
    apiready = function () {

        //菜单参数
        var query = api.pageParam.query;
        //查询条码解析规则
        initScanRule();
        // var ywble = api.require('ywble');
        // ywble.isBleOpen(function (ret, err) {
        //     api.alert({
        //         msg: JSON.stringify(ret)
        //     })
        // });
        // ywble.scan(function (ret, err) {
        //     api.alert({
        //         msg: JSON.stringify(ret)
        //     })
        // });
        // var ble = api.require('ble');
        // alert("2" + JSON.stringify(ble))
        // ble.initManager(function (ret) {
        //     if (ret.state == "poweredOn") {
        //         api.alert({ msg: "初始化成功11" });
        //         ble.scan({
        //             // serviceUUIDs: ['', '']
        //         }, function (ret) {
        //             if (ret.status) {
        //                 alert('开始扫描22');
        //                 var int = self.setInterval(function () {  // 这个方法是说在延迟两秒后执行大括号里的方法
        //                     ble.stopScan();
        //                     var inti = self.setInterval(function () {  // 这个方法是说在延迟两秒后执行大括号里的方法
        //                         ble.getPeripheral(function (ret) {
        //                             alert(JSON.stringify("44:" + JSON.stringify(ret)));
        //                             if (ret) {
        //                                 api.alert({ msg: JSON.stringify(ret) });
        //                             }
        //                         });
        //                     }, 3000)
        //                 }, 30000)


        //             }
        //         });
        //     }
        // });
    }

    //查询扫描规则
    function initScanRule() {
        var serverUrl = localStorage.getItem('serverUrl');
        var un = localStorage.getItem("un");
        var url = serverUrl + "/app/getTmScanRule";
        var data = {
            values: {
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    scanRule = myobj.scanRule
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }




    // 获取光标所在组件的id
    function getIdSelector() {
        var e = event || window.event;
        var el = e.srcElement || e.target;
        idSelector = el.id;
        $("#" + el.id).select();
    }

    //扫描
    function doScan() {
        var moduleScanner = api.require('moduleScanner');
        var params = {
            top: 150, //扫描窗口的上边距
            width: 250, //扫描窗口的宽
            height: 250, //扫描窗口的高
            useColor: false, //是否使用自己设定的颜色(startColor和endColor),
            //如果不使用设定的颜色就使用默认的那张网格图
            startColor: '#0F08C8FF', //渐变起始颜色
            endColor: '#7F08C8FF', //渐变结束颜色
            animTime: 2200, //扫描动画时间,单位为毫秒
        };
        moduleScanner.toScannerActivityForResult(params, function (ret, err) {
            //alert(ret);扫码的结果都是编码
            //1：仓库
            if (idSelector == 'workCenterCode') {

                $("#workCenterCode").val(ret);
                //查询仓库
                getWorkCenter(ret, idSelector);

                //2:库位
            } else if (idSelector == 'workCellCode') {

                $("#workCellCode").val(ret);
                //查询库位
                getWorkCell(ret, idSelector);

                //扫描条码
            } else if (idSelector == 'boxnum') {
                tmcheck(ret)
                //                tmSplit(ret);
            } else if (idSelector == 'consignment') {
                //扫描发货单号
                $("#consignment").val(ret);
            }
        });
    }

    //1：仓库扫描校验
    function getWorkCenter(code, inputId) {
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getWorkCenter";
        var data = {
            values: { ////以表单方式提交参数（JSON对象）
                workCenterCode: code,
                mrlCode: "",
                lotCode: "",
                qty: ""
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    var list = eval(myobj.list);
                    workCenterGid = list[0].workCenterGid;
                    workCenterCode = list[0].workCenterCode + ":" + list[0].workCenterName;
                    workCenterName = list[0].workCenterName;
                    console.log(workCenterGid);
                    document.getElementById(inputId).value = workCenterCode;
                    $("#workCellCode").focus();
                    idSelector = "workCellCode";
                    if (code == workcenter && workCellGid == "") {
                        getWorkCell(workcell, idSelector);
                    }
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                    $("#workCenterCode").focus();
                    $("#workCenterCode").select();
                }
            }
        });
    }

    //2：选择仓库
    function goSelectWorkCenter() {
        api.openWin({
            name: 'uwmSelectWorkCenter',
            url: 'uwmSelectWorkCenter.html',
            pageParam: {
                flag: "in",
                name: "wmPurchaseReturnInfo",
                mrlCode: "",
                lotCode: "",
                qty: ""
            }
        });
    }

    //仓库选择后回调函数
    function setWorkCenter(id, code, name) {
        workCenterGid = id;
        workCenterCode = code;
        workCenterName = name;
        //$("#workCenterCode").attr("value",code+":"+name);
        document.getElementById('workCenterCode').value = code + ":" + name;
        $("#workCellCode").focus();
        idSelector = "workCellCode";
    }

    //3；PDA自带扫描回车事件
    $("#workCenterCode").on('keypress', function (e) { //#keyword为input文本框
        var keycode = e.keyCode;
        var sm = $(this).val();
        if (keycode == '13') {

            //仓库编码
            $("#workCenterCode").val(sm);
            // console.log("扫描回车事件：" + sm);
            //校验改箱码是否存在
            getWorkCenter(sm, "workCenterCode");
        }
    });

    //5:库位扫描校验
    function getWorkCell(code, inputId) {
        //扫库位前先扫仓库
        if (inputId == "workCellCode") {
            if (workCenterGid == "" || workCenterGid == null || workCenterGid == undefined) {
                api.toast({
                    msg: "请先选择/扫描 仓库",
                    duration: 3000
                });
                $("#workCellCode").val("");
                workCellCode = "";
                workCellGid = "";
                workCellName = "";
                return;
            }
        }
        var un = localStorage.getItem("un");
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getWorkCell";
        var data = {
            values: {
                flag: "in_rk", //库内库间标识（out_kn库内  out_kj库间,in_rk入库出库）
                workCenterGid: workCenterGid, //仓库GID
                workCellCode: code, //库位编码
                relWorkCellGid: "", //调入库位
                tm: "",
                workCellFlag: "", //原库位调入库位flag
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    var list = eval(myobj.list);
                    workCellGid = list[0].workCellGid;
                    workCellCode = list[0].workCellCode + ":" + list[0].workCellName;
                    workCellName = list[0].workCellName;
                    document.getElementById(inputId).value = workCellCode;
                    $("#boxnum").focus();
                    idSelector = "boxnum";

                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                    $("#workCellCode").focus();
                    $("#workCellCode").select();
                }
            }
        });
    }

    //6：选择库位
    function goSelectWorkCell() {
        var tm = $("#tm").val();
        //仓库非空校验
        if (workCenterGid == "" || workCenterGid == null || workCenterGid == undefined) {
            api.toast({
                msg: "请先选择/扫描 仓库",
                duration: 3000
            });
            return;
        }

        api.openWin({
            name: 'uwmSelectWorkCell',
            url: 'uwmSelectWorkCell.html',
            pageParam: {
                flag: "in_rk",
                name: "wmPurchaseReturnInfo",
                tm: tm,
                workCenterGid: workCenterGid,
                relWorkCellGid: "",
                workCellFlag: ""
            }
        });
    }

    //库位选择后回调函数
    function setWorkCell(id, code, name) {
        workCellGid = id;
        workCellCode = code;
        workCellName = name;
        document.getElementById('workCellCode').value = code + ":" + name;
        $("#boxnum").focus();
        var e = "boxnum";
        idSelector = e;
    }

    //7；PDA自带扫描回车事件-库位
    $("#workCellCode").on('keypress', function (e) { //#keyword为input文本框
        var keycode = e.keyCode;
        var sm = $(this).val();
        if (keycode == '13') {

            //仓库编码
            $("#workCellCode").val(sm);
            //校验改箱码是否存在
            getWorkCell(sm, "workCellCode");
        }
    });



    //查询库位标识
    function searchFlag(workCellGid) {
        var flag = "";
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/uwmOutOfSearchFlag";
        var data = {
            values: { ////以表单方式提交参数（JSON对象）
                workCellGid: workCellGid, //库位GID
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == '0') {

                    flag = myobj.flag;
                    console.log('库位确认标识：' + flag);
                    return flag;
                } else if (myobj.code == '1') {

                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });

    }

    //出库保存
    function save() {
        if (!clickThrottle()) {
            return;
        }
        const submitButton = document.getElementById('submitButton');

        submitButton.style.pointerEvents = "none"

        remark = $("#remark").val();
        //console.log("list:" + JSON.stringify(arrSave));
        if (arrSave.length <= 0) {
            api.toast({
                msg: "没有需要保存数据",
                duration: 3000
            });
            submitButton.style.pointerEvents = "auto"
            return
        }
        api.showProgress({
            title: '保存中...',
        });
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/uwmreturnInfo";
        var data = {
            values: {
                workCenterGid: workCenterGid, //仓库id
                workCellGid: workCellGid, //库位编码
                remark: remark,
                list: JSON.stringify(arrSave),
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == '0') {
                    api.hideProgress();
                    submitButton.style.pointerEvents = "auto"
                    arrSave = [];
                    html = "";
                    //清空表单
                    $api.html($api.byId("tbodyHtml"), "");
                    $("#boxnum").focus();
                    idSelector = "boxnum";
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                    $("#supplier").val("");
                } else if (myobj.code == '1') {
                    api.hideProgress();
                    submitButton.style.pointerEvents = "auto"
                    $("#boxnum").val("");
                    $("#boxnum").select();
                    $("#supplier").val("");
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } else {
                api.hideProgress();
                submitButton.style.pointerEvents = "auto"
            }
        });
    }



    //自动保存
    function saveAuto() {

        //物料号
        var mrlCode = $("#mrlCode").val();
        //批次号
        var lotCode = $("#lotCode").val();
        //数量
        var qty = $("#qty").val();
        //条码
        var tm = $("#tm").val();
        //箱号
        var boxnum = $("#boxnum").val();
        //条码
        var tmID = $("#tmID").val();

        if (boxnum == "" || boxnum == null || boxnum == undefined) {
            api.toast({
                msg: '箱号不能为空',
                duration: 3000
            });
            return;
        }

        //物料非空校验
        if (mrlCode == "" || mrlCode == null || mrlCode == undefined) {
            api.toast({
                msg: '物料号不能为空',
                duration: 3000
            });
            return;
        }

        //批次号非空校验
        if (lotCode == "" || lotCode == null || lotCode == undefined) {
            api.toast({
                msg: '批次号不能为空',
                duration: 3000
            });
            return;
        }

        //数量非空校验
        if (qty == "" || qty == null || qty == undefined) {
            api.toast({
                msg: '请输入出库数量',
                duration: 3000
            });
            return;
        } else {
            if (parseFloat(qty) <= 0) {
                api.toast({
                    msg: '出库数量必须大于0',
                    duration: 3000
                });
                return;
            }
        }

        $("#boxnum").focus();
        $("#boxnum").select();
        //判断箱号是否重复
        for (var i = 0; i < arrSave.length; i++) {
            if ($("#boxnum").val() == arrSave[i].boxnum) {
                api.toast({
                    msg: '箱号已存在！',
                    duration: 3000
                });
                return;
            }
        }
        var model = {
            mrlCode: mrlCode, //物料号
            lotCode: lotCode, //批次号
            qty: qty, //转移数量
            tm: tm, //条码
            boxnum: boxnum, //箱号
            tmID: tmID //条码ID
        }
        arrSave.push(model);
    }


    //扫描之后条码解析
    function tmSplit(sm) {
        $("#tm").val(sm);
        //直接解析
        if (scanRule == "old") {

            //本地解析
            localAnalyze(sm);

        } else {
            //后台解析
            postAnalyze(sm);
        }
    }

    //本地解析
    function localAnalyze(sm) {
        var arr = sm.split(",");
        if (arr[1] == null || arr[1] == undefined) {
            $("#mrlCode").val("");
        } else {
            $("#mrlCode").val(arr[1]);
        }
        if (arr[2] == null || arr[2] == undefined) {
            $("#qty").val("");
        } else {
            $("#qty").val(arr[2]);
        }
        if (arr[3] == null || arr[3] == undefined) {
            $("#lotCode").val("");
        } else {
            $("#lotCode").val(arr[3]);
        }
        if (arr[4] == null || arr[4] == undefined) {
            $("#tmID").val("");
        } else {
            $("#tmID").val(arr[4]);
        }
        if (arr[9] == null || arr[9] == undefined) {
            $("#boxnum").val("");
        } else {
            $("#boxnum").val(arr[9]);
        }

        //表格
        tableAdd();
    }

    //后台解析条码
    function postAnalyze(sm) {
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/analysisBarCodeCommon";
        var data = {
            values: {
                tm: sm, //条码
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == '0') {

                    var map = myobj.data;
                    lotCode = map.lotCode;
                    boxnum = map.boxnum;
                    mrlCode = map.mrlCode;
                    qty = map.qty;
                    tmID = map.tmID;
                    supplierCode = map.supplierCode;
                    console.log(supplierCode)
                    console.log(boxnum)
                    console.log(JSON.stringify(map))
                    for (var key in map) {
                        $("#" + key).val(map[key]);
                    }
                    //表格
                    tableAdd(lotCode, boxnum, mrlCode, qty, supplierCode, sm, tmID);
                } else if (myobj.code == '1') {

                    $("#boxnum").val("");
                    $("#boxnum").select();
                    $("#supplier").val("");
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } else {
                alert(JSON.stringify(err));
            }
        });
    }

    function tmcheck(tm) {
        console.log(tm)
        var arr = tm.split(",");
        if (arr[0] == "") {
            api.toast({
                msg: '条码不是标准供应商条码，不允许退货',
                duration: 3000
            });
            $("#boxnum").val("");
            $("#boxnum").select();
            $("#supplier").val("");
            return;
        }
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/tmcheck";
        var data = {
            values: {
                tm: tm, //条码
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 300,
            returnAll: false,
            data: data
        }, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == '0') {
                    supplier = myobj.supplierCode + ':' + myobj.supplierName
                    $("#supplier").val(supplier);
                    console.log(supplier)

                    tmSplit(tm)
                } else if (myobj.code == '1') {
                    $("#boxnum").val("");
                    $("#boxnum").select();
                    $("#supplier").val("");
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } else {
                alert(JSON.stringify(err));
            }
        });


    }


    function tableAdd(lotCode, boxnum, mrlCode, qty, supplierCode, tm, tmID) {
        //判断箱号是否重复
        for (var i = 0; i < arrSave.length; i++) {
            if ($("#boxnum").val() == arrSave[i].boxnum) {
                $("#boxnum").val("");
                api.toast({
                    msg: '箱号已存在！请勿重复扫描',
                    duration: 3000
                });
                return;
            }
        }
        $("#boxnum").val("");
        workCenterCode = $("#workCenterCode").val()
        workCellCode = $("#workCellCode").val()

        html += "<tr style='text-align: center;color: black;font-size: 12px;background-color: #F5F5F5;' >";
        html += "<td name='boxnum'>" + boxnum + "</td>";
        html += "<td name='mrlCode'>" + mrlCode + "</td>";
        html += "<td name='lotCode'>" + lotCode + "</td>";
        html += "<td name='qty'>" + qty + "</td>";
        html += "<td name='workCenterCode'>" + workCenterCode + "</td>";
        html += "<td name='workCellCode'>" + workCellCode + "</td>";
        html += "<td name='supplierCode'>" + supplierCode + "</td>";
        html += "</tr>";

        $api.html($api.byId("tbodyHtml"), html);
        idSelector = "boxnum";
        var model = {
            mrlCode: mrlCode, //物料号
            lotCode: lotCode, //批次号
            qty: qty, //转移数量
            tm: tm, //条码
            boxnum: boxnum, //箱号
            supplierCode: supplierCode,
            tmID: tmID
        }

        arrSave.push(model);
        console.log(JSON.stringify(arrSave));

    }

    //箱号监听回车事件
    $("#boxnum").on('keypress', function (e) { //#keyword为input文本框
        var keycode = e.keyCode;
        if (keycode == '13') {
            var tm = $(this).val();
            $("#boxnum").select();
            //调用条码解析+保存事件
            //           tmSplit(tm);
            tmcheck(tm);
        }
    });

    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>